package com.example.mobile2030606150cjk0427;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class ParkingRVAdapter extends RecyclerView.Adapter<ParkingRVAdapter.ViewHolder> {
    private List<Parking> list;

    public ParkingRVAdapter(List<Parking> list) {
        this.list = list;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_rv_main_parking, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        Parking parking = list.get(position);
        holder.tv1.setText(parking.getTv1());
        holder.tv2.setText(parking.getTv2());
        holder.tv3.setText(parking.getTv3());
        holder.tv4.setText(parking.getTv4());
        holder.tv5.setText(parking.getTv5());
        holder.tv6.setText(parking.getTv6());
        holder.im1.setImageResource(parking.getIm1());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        TextView tv1, tv2, tv3, tv4, tv5, tv6;
        ImageView im1;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tv1 = itemView.findViewById(R.id.textView1);
            tv2 = itemView.findViewById(R.id.textView2);
            tv3 = itemView.findViewById(R.id.textView3);
            tv4 = itemView.findViewById(R.id.textView4);
            tv5 = itemView.findViewById(R.id.textView5);
            tv6 = itemView.findViewById(R.id.textView6);
            im1 = itemView.findViewById(R.id.imageView1);
        }
    }
}
